// DocumentReportWebPage.cpp: implementation of the CDocumentReportWebPage class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "AUSlotsTester.h"
#include "DocumentReportWebPage.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CDocumentReportWebPage::CDocumentReportWebPage( const CAUSlotsTesterDoc* pDoc ) :
	CDocumentWebPage( pDoc ),
	m_wpHome( pDoc ),
	m_wpStatisticalAnalysis( pDoc ),
	m_wpPayoutHistory( pDoc )
{
}

CDocumentReportWebPage::~CDocumentReportWebPage()
{
	for ( int n = 0; n < m_awpGameModes.GetSize(); n++ )
	{
		CDocumentGameModeWebPage* pWP = m_awpGameModes[ n ];

		delete pWP;
	}
}

void CDocumentReportWebPage::InitializeGameModes()
{
	const CGameModeArray& modes = GetDocument().GetGameModeArray();

	for ( int n = 0; n < modes.GetSize(); n++ )
	{
		CDocumentGameModeWebPage* pWP = new CDocumentGameModeWebPage( &GetDocument(), modes[n].m_nID );

		m_awpGameModes.Add( pWP );
	}
}

void CDocumentReportWebPage::GenerateBodyContent()
{
	m_wpHome.ResetContent();
	m_wpHome.GenerateBodyContent();

	BeginHeading( 3, haCenter );

		InsertContent( _T( "Summary" ) );
	
	EndHeading( 3 );

	InsertContent( m_wpHome.GetFileContents() );

	m_wpStatisticalAnalysis.ResetContent();
	m_wpStatisticalAnalysis.GenerateBodyContent();

	BeginHeading( 3, haCenter );

		InsertContent( m_wpStatisticalAnalysis.GetSubTitle() );
	
	EndHeading( 3 );
	
	InsertContent( m_wpStatisticalAnalysis.GetFileContents() );

	for ( int n = 0; n < m_awpGameModes.GetSize(); n++ )
	{
		CDocumentGameModeWebPage* pWP = m_awpGameModes[ n ];

		pWP->ResetContent();
		pWP->GenerateBodyContent();

		BeginHeading( 3, haCenter );

			InsertContent( pWP->GetSubTitle() );
		
		EndHeading( 3 );
		
		InsertContent( pWP->GetFileContents() );
	}

	m_wpPayoutHistory.ResetContent();
	m_wpPayoutHistory.GenerateBodyContent();

	BeginHeading( 3, haCenter );

		InsertContent( m_wpPayoutHistory.GetSubTitle() );
	
	EndHeading( 3 );
	
	InsertContent( m_wpPayoutHistory.GetFileContents() );
}

LPCTSTR CDocumentReportWebPage::GetSubTitle() const
{
	return _T( "Full Report" );
}
